import React, { useRef } from 'react';
import { connect } from 'dva';

const LayoutIframeDOM = (props) => {
  const { menuKey, iframeUrl } = props;
  const iframeRef = useRef();
  return (
    <iframe
      id={menuKey}
      src={iframeUrl}
      ref={iframeRef}
      scrolling="yes"
      frameBorder="none"
      name={`manage-admin-iframe_${menuKey}`}
      allow="autoplay;microphone;camera;midi;encrypted-media;"
      style={{ width: '100%', height: '100%', overflow: 'hidden' }}
    ></iframe>
  );
};

export default connect(({ layoutApi }) => ({
  menuKey: layoutApi.menuKey,
  iframeUrl: layoutApi.iframeUrl,
}))(LayoutIframeDOM);
